﻿using System;
using System.Collections.Generic;
using Luna.Data.Configuration;
using Luna.Data.CRM;
using Luna.Data.Test;

namespace Luna.Data.CRM
{
    internal class CategoryTest : DataWithReferenceTest<IContactProvider, ICategoryData>
    {
        private const string DESCRIPTION = "Description";

        private const string NAME = "Name";

        public CategoryTest(string contextName)
            : base(contextName)
        {
        }

        public override Action<IReferenceData> Delete
        {
            get { return Service.CategoryDelete; }
        }

        public override Predicate<ICategoryData> DeletePredicate
        {
            get { return x => x.Name.StartsWith(TEST_PREFIX); }
        }

        public override Func<IReferenceData, ICategoryData> Get
        {
            get { return Service.CategoryGet; }
        }

        public override Func<IEnumerable<ICategoryData>> GetAll
        {
            get { return Service.CategoryGetAll; }
        }

        public override Action<ICategoryData> Save
        {
            get { return Service.CategorySave; }
        }

        public override bool AreSame(ICategoryData P_Entity1, ICategoryData P_Entity2)
        {
            bool L_Return = base.AreSame(P_Entity1, P_Entity2);

            L_Return &= P_Entity1.PK == P_Entity2.PK;
            L_Return &= P_Entity1.Name == P_Entity2.Name;
            L_Return &= P_Entity1.Description == P_Entity2.Description;

            return L_Return;
        }

        public override ICategoryData Create()
        {
            ICategoryData L_Entity = base.Create();
            LoadEntity(L_Entity);
            L_Entity.Name = GetString(NAME);
            L_Entity.Description = GetString(DESCRIPTION);
            return L_Entity;
        }
    }
}